const express = require("express");
const { resolve } = require("path");

const { Wechat } = require("wechat-jssdk");

const wx = new Wechat({
  appId: "wx8429dc7f50245214",
  appSecret: "ce0a8a8fecd94ebe5345691f3b2b488d",
});

const app = express();

app.use("/static", express.static(resolve(__dirname, "public")));

app.set("views", resolve(__dirname, "views"));
app.set("view engine", "html");
app.engine("html", require("express-art-template"));

app.get("/", (req, res) => {
  wx.jssdk
    .getSignature("http://192.168.0.103:3000/")
    .then((data) => {
      console.log(data);
      res.render("index", data);
    })
    .catch((err) => {
      console.log(err);
      res.send(err);
    });
});

app.listen(3000);
